#include <context.hpp>
#include "walle.hpp"
#include "robot/serial/serial.hpp"
#include "robot/serial/unix.hpp"
#include "robot/serial/win.hpp"
#include "vision/detector/hog_svm/hog_svm.hpp"
#include "vision/tracker/kcf/kcftracker.hpp"

int main() {
	Detector* detector = new HogSvm("hog_svm_model_phantom3.xml");
	Tracker* tracker = new KCFTracker();
	Vision* vision = new Vision(detector, tracker);
	Serial* serial = new WinSerial(ROBOT_WINDOWS_COMM);
	Robot* robot = new Robot(serial);
	Walle walle(vision, robot);
	cv::VideoCapture cap(0);
	if (!cap.isOpened()) {
		delete robot;
		delete serial;
		delete vision;
		delete tracker;
		delete detector;
		std::cout << "fail to open camera,return code -1" << std::endl;
		return -1;
	}
	cv::Mat frame;
	while (1) {
		cap >> frame;
		walle.guide(frame);
	}
	delete robot;
	delete serial;
	delete vision;
	delete tracker;
	delete detector;
	return 0;
}
